<!-- REQUIRED SCRIPTS AND STYLES -->
<?php if(file_exists(JS_INCLUDE_PATH.'jquery/ui/themes/smoothness/jquery-ui-1.8.16.custom.css')): ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_INCLUDE_URL; ?>jquery/ui/themes/smoothness/jquery-ui-1.8.16.custom.css" />
<?php endif; ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jsTree_1.0/themes/themeroller/style.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jqGrid/css/ui.jqgrid.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<?php if(file_exists(JS_INCLUDE_PATH.'jquery/ui/i18n/jquery.ui.datepicker-'.LANG.'.js')): ?>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/ui/i18n/jquery.ui.datepicker-<?php echo LANG; ?>.js"></script>
<?php endif; ?>
<?php if(file_exists(JS_INCLUDE_PATH.'jquery/plugins/jqGrid/i18n/grid.locale-'.LANG.'.js')): ?>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jqGrid/i18n/grid.locale-<?php echo LANG; ?>.js"></script>
<?php else: ?>
<script src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jqGrid/i18n/grid.locale-en.js" type="text/javascript"></script>
<?php endif; ?>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jqGrid/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/ui/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/fancybox/jquery.fancybox.js?v=2.0.6"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/fancybox/helpers/jquery.fancybox-thumbs.js?v=1.0.2"></script>
<link rel="stylesheet" type="text/css" href="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/fancybox/jquery.fancybox.css?v=2.0.6" media="screen" />
<link rel="stylesheet" type="text/css" href="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/fancybox/helpers/jquery.fancybox-thumbs.css?v=1.0.2" />
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.cookie.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.hotkeys.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jsTree_1.0/jquery.jstree.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.numeric.pack.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.floatnumber.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.autogrow.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/jquery.textlimit.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/tablesorter/tablesorter-filter/tablesorter.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/tablesorter/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/tablesorter/jquery.tablesorter.filter.js"></script>
<script type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/interface/interface.js"></script>
<?php if($_GET['stat'] > 0): ?>
<script language="javascript" type="text/javascript" src="<?php echo JS_INCLUDE_URL; ?>jquery/plugins/flot/jquery.flot.pack.js"></script>
<?php endif; ?>
<script type="text/javascript">
	jQuery(document).ready(function() 
	{
		jQuery('textarea.autogrow').autogrow(
		{
			minHeight: 14,
			lineHeight: 13
		});
		jQuery('textarea.limit_50').textlimit('',50);
       	jQuery('textarea.limit_100').textlimit('',100);
		jQuery('textarea.limit_150').textlimit('',150);
		jQuery('textarea.limit_200').textlimit('',200);
		jQuery('textarea.limit_250').textlimit('',250);
       	jQuery('textarea.limit_300').textlimit('',300);
		jQuery('textarea.limit_400').textlimit('',400);
       	jQuery('textarea.limit_500').textlimit('',500);
		
		<?php if(!($_GET['print'] > 0)): ?>
		jQuery('input.numeric').numeric();
		jQuery('input.int').numeric();
		jQuery('input.tinyint').attr({ maxlength: "1" });
		jQuery('input.smallint').attr({ maxlength: "4" });
		jQuery('input.max_500').attr({ maxlength: "500" });
		jQuery('input.max_250').attr({ maxlength: "250" });
		jQuery('input.max_200').attr({ maxlength: "200" });
		jQuery('input.max_100').attr({ maxlength: "100" });
		jQuery('input.max_80').attr({ maxlength: "80" });
		jQuery('input.max_60').attr({ maxlength: "60" });
		jQuery('input.max_50').attr({ maxlength: "50" });
		jQuery('input.max_20').attr({ maxlength: "20" });
		jQuery('input.max_10').attr({ maxlength: "10" });
		/*
		jQuery('#dock').Fisheye(
		{
			maxWidth: 48,
			items: 'a',
			itemsText: 'span',
			container: '.dock-container',
			itemWidth: 24,
			proximity: 40,
			halign : 'center'
		});
		*/
		jQuery(".select_all").click(function()
		{
			var checked_status = this.checked;
			jQuery(".select_list").each(function()
			{ this.checked = checked_status; });
		});
		
		jQuery('a.fancyBox').fancybox({
			 'overlayShow' : true,
			 'transitionIn' : 'elastic',
			 'transitionOut' : 'elastic'
		 });
			
		jQuery( ".date_range_start").datepicker(
		{
			dateFormat: "dd-mm-yy",
			changeMonth: true,
			numberOfMonths: 1,
			showWeek: true,
			onClose: function( selectedDate ) 
			{
				var target = jQuery(this).attr('alt');
				if(target != '')
				{ $("#"+target).datepicker( "option", "minDate", selectedDate ); }
			}
		});
		jQuery( ".date_range_end").datepicker(
		{
			dateFormat: "dd-mm-yy",
			changeMonth: true,
			numberOfMonths: 1, 
			showWeek: true, 
			showAnim: 'fadeIn',
			onClose: function( selectedDate ) 
			{
				var target = jQuery(this).attr('alt');
				if(target != '')
				{ $("#"+target).datepicker( "option", "maxDate", selectedDate ); }
			}
		});
		
		jQuery(".date_pick").datepicker(
		{
			inline: true, 
			buttonImage: 'calendar.gif',
			dateFormat: 'yy-mm-dd',
			minDate: 0,
			showButtonPanel: true,
			rangeSelect: true
		});
		
		var dates = jQuery( ".period_filter_date_start, .period_filter_date_end" ).datepicker(
		{
			inline: true, 
			//showOn: "button",
			buttonImage: "<?php echo SYSICONS_URL; ?>calendar_16.gif",
			buttonImageOnly: true,
			//buttonImage: 'calendar.gif',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: true,
			rangeSelect: true,
			showWeek: true,
			//defaultDate: "-1m",
			//numberOfMonths: 3,
			changeMonth: true,
			onSelect: function( selectedDate ) {
				var option = this.name == "date_start" ? "minDate" : "maxDate",
					instance = $(this).data("datepicker"),
					date = jQuery.datepicker.parseDate(
						instance.settings.dateFormat ||
						jQuery.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
		
		<?php 
		if($user->getLevel() > 4)
	   	{ echo 'load_tree_menu();'; }
		else
		{ echo 'loginDialog();'; }
		?>
		
		jQuery('div.menu_list').addClass('ui-corner-bl ui-corner-br');
		jQuery('fieldset.edit_form').addClass('ui-corner-bl ui-corner-br');
		jQuery('.accordion').accordion({ header: "h3" });
		jQuery('.tabs').tabs({cookie:{expires:1000}}); 
		jQuery.tablesorter.defaults.widgets = ['zebra']; 
		jQuery.tablesorterPager.defaults.positionFixed = false;
		jQuery.tablesorterPager.defaults.size = 40;
		<?php endif; ?>
	});
	
	function setPeriod(submitForm)
	{
		var period = jQuery('.period-select option:selected').val();
		if(period == 'today')
		{
			jQuery(".period_filter_date_start").val('<?php echo date('Y-m-d'); ?>');
			jQuery(".period_filter_date_end").val('<?php echo date('Y-m-').(date('d')+1); ?>');
			if(submitForm == true)
			{ jQuery('#edit_form').submit(); }
		}
		if(period == 'this_month')
		{
			jQuery(".period_filter_date_start").val('<?php echo date('Y-m-').'01'; ?>');
			jQuery(".period_filter_date_end").val('<?php echo date('Y-m-t'); ?>');
			if(submitForm == true)
			{ jQuery('#edit_form').submit(); }
		}
		if(period == 'this_year')
		{ 
			jQuery(".period_filter_date_start").val('<?php echo date('Y-').'01-01'; ?>');
			jQuery(".period_filter_date_end").val('<?php echo date('Y-').'12-31'; ?>');
			if(submitForm == true)
			{ jQuery('#edit_form').submit(); }
		}
		if(period == 'custom')
		{ return; }
		//alert(period);
	}
</script>